package com.douyu.data.config;

import org.springframework.amqp.core.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class RabbitMqConfig {

    @Bean
    public DirectExchange directExchange(){
        return new DirectExchange("test.direct", true, false);
    }
    @Bean
    public FanoutExchange fanoutExchange(){
        return new FanoutExchange("test.fanout", true, false);
    }
    @Bean
    public TopicExchange topicExchange(){
        return new TopicExchange("test.topic", true, false);
    }
    @Bean
    public Queue queue1(){
        return new Queue("queue1", true);
    }

    @Bean
    public Queue queue2(){
        return new Queue("queue2", true);
    }

    @Bean
    public Queue queue3(){
        return new Queue("queue3", true);
    }

    @Bean
    public Binding queue1BindingForDirect(){
        return BindingBuilder.bind(queue1()).to(directExchange()).with("test");
    }

    @Bean
    public Binding queue1Binding(){
        return BindingBuilder.bind(queue1()).to(fanoutExchange());
    }

    @Bean
    public Binding queue2Binding(){
        return BindingBuilder.bind(queue2()).to(fanoutExchange());
    }

    @Bean
    public Binding queue3Binding(){
        return BindingBuilder.bind(queue3()).to(fanoutExchange());
    }
}
